package com.loveprogrammer.oss.common.uploader;

import com.aliyun.oss.OSSClient;

import java.io.InputStream;

/***
 * @author 王旭
 * @version 1.0
 * 流上传
 */
public class InputStreamUploader extends AbstractUploader {
    // 输入流
    private InputStream inputStream;

    public InputStreamUploader() {
    }

    /**
     * @param inputStream 输入流
     * @param uploadPath  路径
     */
    public InputStreamUploader(InputStream inputStream, String uploadPath) {
        super(uploadPath);
        this.inputStream = inputStream;
    }

    public InputStreamUploader(InputStream inputStream, UploadPathBuilder uploadPathBuilder) {
        super(uploadPathBuilder);
        this.inputStream = inputStream;
    }

    /**
     * 输入流上传
     *
     * @param ossClient  客户端
     * @param bucketName 储存名
     */
    @Override
    public void upload(OSSClient ossClient, String bucketName) {
        ossClient.putObject(bucketName, uploadPath, inputStream);
    }
}
